package com.gxa.controller.parking;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gxa.common.utils.Result;
import com.gxa.entity.parking.TemporaryPay;
import com.gxa.entity.parking.TemporarySelect;
import com.gxa.service.parking.TemporaryPayService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;



/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yjl
 * @since 2022-10-11 10:05:39
 */
@Api(tags = "临停缴费")
@RestController
@RequestMapping("/temporary-pay")
public class TemporaryPayController {
    @Autowired
    private TemporaryPayService temporaryPayService;

    @CrossOrigin(origins = "*", maxAge = 3600)//跨越请求配置
    @ApiOperation("展示临停缴费")
    @PostMapping("/temporarylist")
    public Result selectAll(@RequestBody TemporarySelect temporarySelect) {
        PageHelper.startPage(temporarySelect.getPageNum(),temporarySelect.getPageSize());
        List<TemporaryPay> temporaryPays = this.temporaryPayService.selectAll();
        PageInfo<TemporaryPay> te = new PageInfo<>(temporaryPays);
        return Result.success(te);
    }

    @CrossOrigin(origins = "*", maxAge = 3600)//跨越请求配置
    @ApiOperation("按ID查询")
    @GetMapping("/queryById/{id}")
    public TemporaryPay queryById(@PathVariable("id") Integer id){
        return this.temporaryPayService.selectById(id);
    }

    @CrossOrigin(origins = "*", maxAge = 3600)//跨越请求配置
    @ApiOperation("按条件查询")
    @PostMapping("/queryByCondition")
    public Result selectByCondition(@RequestBody TemporarySelect temporarySelect){
        PageHelper.startPage(temporarySelect.getPageNum(),temporarySelect.getPageSize());
        List<TemporaryPay> temporarySelects = this.temporaryPayService.selectByCondition(temporarySelect);
        PageInfo<TemporaryPay> ts = new PageInfo<>(temporarySelects);
        return Result.success(ts);
    }
}
